package com.wgts.wgts.mvp.presenter.imp;

import com.wgts.wgts.mvp.model.IUpgradeShopKeeperFragmentModel;
import com.wgts.wgts.mvp.model.IWgtsProductModel;
import com.wgts.wgts.mvp.presenter.IUpgradeShopKeeperFragmentPresenter;
import com.wgts.wgts.mvp.view.IUpgradeShopKeeperFragmentView;
import com.wgts.wgts.netmodle.HttpResultSubscriber;
import com.wgts.wgts.netmodle.req.WgtsProductListReq;
import com.wgts.wgts.netmodle.resp.SearchShopResultEntity;
import com.wgts.wgts.netmodle.resp.WgtsProductListEntity;

import java.util.List;

public class UpgradeShopKeeperFragmentPresenter implements IUpgradeShopKeeperFragmentPresenter {

    private IUpgradeShopKeeperFragmentModel model;

    private IUpgradeShopKeeperFragmentView view;

    private IWgtsProductModel wgtsProductModel;

    public UpgradeShopKeeperFragmentPresenter(IUpgradeShopKeeperFragmentModel model, IUpgradeShopKeeperFragmentView view, IWgtsProductModel wgtsProductModel) {
        this.model = model;
        this.view = view;
        this.wgtsProductModel = wgtsProductModel;
    }


    @Override
    public void productList(String type) {
        WgtsProductListReq req = new WgtsProductListReq();
        req.productType = type;
        req.pageIndex = "1";
        req.pageIndex = "20";
        wgtsProductModel.initProducteList(req, new HttpResultSubscriber<List<WgtsProductListEntity>>() {
            @Override
            public void onSuccess(List<WgtsProductListEntity> entity) {
                view.productResult(entity);
            }

            @Override
            public void _onError(int status, String msg) {
                view.onError(status, msg);
            }
        });
    }

    @Override
    public void shopKeepPhone() {
        model.shopKeepPhone(new HttpResultSubscriber<String>() {
            @Override
            public void onSuccess(String s) {
                view.shopKeepPhone(s);
            }

            @Override
            public void _onError(int status, String msg) {

            }
        });
    }
}
